home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Circle out fade.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  85 lines

  1. /**********************************************************************\
  2.  
  3. File:        Circle out fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define    gap            4        /* difference between one radius and the next */
  28. #define CorrectTime 2
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30. #define theWindowWidth (boundsRect.right-boundsRect.left)
  31.  
  32. pascal short CircleOutFade(Rect boundsRect, Pattern *thePattern);
  33.  
  34. /* Make a circular region and use it as the mask in CopyBits.  Lots of overlap,
  35.    but masked by timing correction.  If you want to optimize it, look at the
  36.    donut region code in "Circle in.c" */
  37.    
  38. pascal short CircleOutFade(Rect boundsRect, Pattern *thePattern)
  39. {
  40.     Rect            theRect;
  41.     int                cx, cy;
  42.     RgnHandle        curregion, boundsRgn, sectrgn;
  43.     Point            zeroPoint;
  44.     
  45.     zeroPoint.h=boundsRect.left;
  46.     zeroPoint.v=boundsRect.top;
  47.     
  48.     cx = theWindowWidth / 2;
  49.     cy = theWindowHeight / 2;
  50.     
  51.     theRect.left=cx-gap;         /* circumscribing rectangle for circle */
  52.     theRect.right=cx+gap;
  53.     theRect.top=cy-gap;
  54.     theRect.bottom=cy+gap;
  55.     OffsetRect(&theRect, boundsRect.left, boundsRect.top);
  56.     
  57.     boundsRgn=NewRgn();
  58.     RectRgn(boundsRgn, &boundsRect);
  59.     sectrgn=NewRgn();
  60.     curregion=NewRgn();
  61.     
  62.     do
  63.     {
  64.         StartTiming();
  65.         SetEmptyRgn(curregion);
  66.         OpenRgn();
  67.             FrameOval(&theRect);   /* the circle region */
  68.         CloseRgn(curregion);
  69.         SectRgn(curregion, boundsRgn, sectrgn);
  70.         FillRgn(sectrgn, *thePattern);
  71.         theRect.left-=gap;        /* make the rect bigger (and thus the circle) */
  72.         theRect.right+=gap;
  73.         theRect.top-=gap;
  74.         theRect.bottom+=gap;
  75.         TimeCorrection(CorrectTime);
  76.     }
  77.     while (!PtInRgn(zeroPoint, curregion));
  78.     
  79.     DisposeRgn(curregion);
  80.     DisposeRgn(boundsRgn);
  81.     DisposeRgn(sectrgn);
  82.     
  83.     return 0;
  84. }
  85.